import { useUserMenu } from "@/store/userStore";

export const useAuth = () => {
	// 获取用户权限信息
	const permissions = useUserMenu();

	const hasPermission = (requiredPerms: string) => {
		if (permissions && permissions.length === 0) return false;
		if (requiredPerms === "*:*:*") return true;
		const targetPermission = requiredPerms.toLocaleLowerCase();
		return permissions?.some((item) => item.permission === targetPermission) ?? false;
	};

	return { hasPermission };
};
